//深度遍历ast
function traverserNode(ast) {
    //直接修改原始数据？？感觉不大好
    const currentNode = ast;
    //对当前节点进行操作
    if (currentNode.type == "Element" && currentNode.tag == "p") {
        //见所有的p标签转换成"h1";
        currentNode.tag = "h1";
    }
    //如果节点的类型为Text
    //重复内容两次
    if (currentNode.type === "Text") {
        currentNode.content = currentNode.content.repeat(2);
    }

    //如果有子节点，则递归地调用traverseNode函数进行遍历
    const children = currentNode.children;
    if (children) {
        for (let i = 0; i < children.length; i++) {
            traverserNode(children[i]);
        }
    }
}

//封装transform函数，来对AST进行转换
function transform(ast) {
    traverserNode(ast);
    console.log(dump(ast));
}